package recycle.impl;

import org.springframework.stereotype.Service;
import recycle.dao.RecycleemployeerecordMapper;
import recycle.pojo.Recycleemployeerecord;
import recycle.service.RecycleemployeerecordService;
import recycle.utils.Page;
import recycle.vo.RecycleemployeerecordParam;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
* 描述：回收人员分配记录表 服务实现层接口
* @author 孙冉
* @date 2019/07/22
*/
@Service
public class RecycleemployeerecordServiceImpl implements RecycleemployeerecordService{
	@Resource
	private RecycleemployeerecordMapper recycleemployeerecordMapper;
 	
 	/**
    * 描述：根据Id获取Recycleemployeerecord对象
    */
    public Recycleemployeerecord findById(Serializable recordId){
    	return recycleemployeerecordMapper.findById(recordId);
    }
    /**
    * 描述：获取所有的Recycleemployeerecord对象
    */
    public List<Recycleemployeerecord> findAll(){
    	return recycleemployeerecordMapper.findAll();
    }

	/**
    * 描述：新增保存Recycleemployeerecord对象
    */
    public int save(Recycleemployeerecord recycleemployeerecord){
    	return  recycleemployeerecordMapper.save(recycleemployeerecord);
    }

	/**
    * 描述：根据Id删除Recycleemployeerecord对象

    */
    public int delete(Serializable recordId){
    	return  recycleemployeerecordMapper.delete(recordId);
    }
	
	/**
    * 描述：更新Recycleemployeerecord对象
    */
    public int update(Recycleemployeerecord recycleemployeerecord){
    	return  recycleemployeerecordMapper.update(recycleemployeerecord);
    }
    
    /**
     * 根据不确定的条件，动态查询
     */
    public List<Recycleemployeerecord> query(RecycleemployeerecordParam param){
    	return  recycleemployeerecordMapper.query(param);
    }
    
    /**
     * 根据不确定的条件，动态分页查询
     */
    public Page queryByPage(RecycleemployeerecordParam param){
    	Page page = new Page();
    	if(param.isPage()){
			int totalCount = recycleemployeerecordMapper.getCount(param);
			int totalPageCount = (totalCount-1)/page.getPageSize()+1;
			if(param.getPageIndex()<1){
				param.setPageIndex(1);
			}else if(param.getPageIndex()>totalPageCount){
				param.setPageIndex(totalPageCount);
			}
			List list = recycleemployeerecordMapper.query(param);

			page.setTotalCount(totalCount);
			page.setTotalPageCount(totalPageCount);
    		page.setPageNo(param.getPageIndex());
    		page.setPageSize(param.getSize());
			page.setList(list);
		}
    	return page;
    	
    }

	@Override
	public List<Recycleemployeerecord> findAllEmployee() {
		return recycleemployeerecordMapper.findAllEmployee();
	}

}
